package com.epoch.servicecourse.service.impl;

import com.epoch.servicecourse.bean.CourseType;
import com.epoch.servicecourse.dao.CourseTypeDao;
import com.epoch.servicecourse.service.CourseTypeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import utils.AssertUtil;

import javax.annotation.Resource;

/**
 * @author
 */
@Service
@Slf4j
public class CourseTypeServiceImpl implements CourseTypeService {
    @Resource
    private CourseTypeDao courseTypeDao;

    @Override
    public CourseType getTypeById(String courseId){
        //非空校验，判断课程编号是否为空
        AssertUtil.isTrue(StringUtils.isBlank(courseId),"课程编号不能为空！");
        //判断记录是否存在
        AssertUtil.isTrue(courseTypeDao.getTypeById(courseId)==null,"找不到记录！");
        //查询课程类型
        return courseTypeDao.getTypeById(courseId);
    }
}
